package cn.oracle.eshop.cart.controller;


import cn.oracle.eshop.cart.service.ShoppingCartService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**购物车管理模块的controller组件
 * @author wyh
 * @ClassName ShoppingCartController
 * @date 2022/3/28 /21:54
 */
@Slf4j
@RestController
@RequestMapping("/cart")
public class ShoppingCartController {
    @Autowired
    private ShoppingCartService shoppingCartService;
    /***
     * 添加购物车的商品条目
     * @author wyh
     * @date 2022/3/28
     * @param userAccountId 用户账号ID
     * @param goodsSkuId 商品SKUId
     * @return 处理结果
    */
    @PostMapping("/item/add")
    public Boolean addShoppingCartItem(Long userAccountId,Long goodsSkuId){
        try {
           return shoppingCartService.addShoppingCartItem(userAccountId,goodsSkuId);

        } catch (Exception e) {
            log.error("error:{}",e);
                return false;
        }

    }
}
